home *** CD-ROM | disk | FTP | other *** search
Text File | 2003-07-17 | 60.6 KB | 2,175 lines |
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // ----------------------------------------------------------------------------
- // Utility procedures used by other procedures in this file
- //
-
- proc setParentToCommonTab()
- {
- setParent `rendererTabLayoutName("mayaSoftware")`;
- setParent commonTabColumn;
- }
-
- // ----------------------------------------------------------------------------
- // Code to create and update the file name preview area
- //
-
- proc createTargetFilePreview()
- {
- string $oldParent = `setParent -query`;
-
- columnLayout
- -adjustableColumn true
- targetFilePreview;
-
- text
- -align "left"
- -font "boldLabelFont"
- -label "Path"
- exampleText0;
- text
- -align "left"
- -font "boldLabelFont"
- -label "File Name"
- exampleText1;
- text
- -align "left"
- -font "boldLabelFont"
- -label "To"
- exampleText2;
-
- setParent $oldParent;
-
- // This target file preview is affected by a number of attributes.
- // If any of those attributes change, this preview needs to be updated.
- //
- // Here we fill an array with the names of all of the current renderer's
- // attributes which affect the naming of the target file.
- //
- string $attrArray[];
-
- $attrArray[size($attrArray)] = "defaultRenderGlobals.imageFilePrefix";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.outFormatControl";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.imageFormat";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.outFormatExt";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.animation";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.imageFormat";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.byFrameStep";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.extensionPadding";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.startFrame";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.endFrame";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.modifyExtension";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.startExtension";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.byExtension";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.periodInExt";
- $attrArray[size($attrArray)] = "defaultResolution.fields";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.fieldExtControl";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.oddFieldExt";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.evenFieldExt";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.putFrameBeforeExt";
-
- // Now we establish scriptJobs to invoke the procedure which updates the
- // target file preview when any of the above attributes change.
- //
- int $i;
-
- for ($i = 0; $i < size($attrArray); $i++)
- {
- scriptJob
- -attributeChange
- $attrArray[$i]
- "updateMayaSoftwareTargetFilePreview"
- -parent targetFilePreview;
- }
-
- scriptJob
- -parent targetFilePreview
- -event
- workspaceChanged
- "updateMayaSoftwareTargetFilePreview";
- }
-
- global proc updateMayaSoftwareTargetFilePreview()
- {
- //
- // Description:
- // This procedure is called any time an attribute change occurs which
- // would affect the name(s) of the file(s) that would be created when the
- // user performs a render.
- // This procedure updates the lines of text in the General tab that allow
- // the user to see what files are going to be created when they render.
- //
-
- string $oldParent = `setParent -query`;
-
- string $renderer = "mayaSoftware";
- string $tabLayout = rendererTabLayoutName($renderer);
- setParent $tabLayout;
-
- //
- // Update the Path portion of the preview.
- //
-
- // get the project's image directory
- //
- string $imgDir = `workspace -q -rte "images"`;
- string $fullPath = `workspace -expandName $imgDir`;
-
- $path = " Path: "+ $fullPath + "/";
-
- text -edit -label $path exampleText0;
-
- //
- // Update the File Name portion of the preview.
- //
-
- string $title1 = " File Name: ";
- string $title2 = " To: ";
-
- string $prefix = `getAttr defaultRenderGlobals.imageFilePrefix`;
-
- if ($prefix == "")
- {
- $prefix = getSceneName();
- }
-
- // Image extension
- string $imageType;
- int $imageUse = `getAttr "defaultRenderGlobals.outFormatControl"`;
- if ($imageUse == 1)
- {
- // Don't use extension
- $imageType = "";
- }
- else if ($imageUse == 0)
- {
- // Show the extension
- global string $imgExt[]; // This is the actual file extension
- global int $imgExtNum[]; // This is the corresponding internal value
-
- int $imageNum = `getAttr "defaultRenderGlobals.imageFormat"`;
- for ($i=0; $i < size($imgExtNum); ++$i)
- {
- if ($imageNum == $imgExtNum[$i])
- {
- $imageType = $imgExt[$i];
- break;
- }
- }
- }
- else if ($imageUse == 2)
- {
- // User specified
- $imageType = `getAttr "defaultRenderGlobals.outFormatExt"` ;
- }
-
- // Frames number extension
- string $frame1 = "";
- string $frame2 = "";
- int $useAnim = `getAttr "defaultRenderGlobals.animation"`;
-
- // If we have an animation file format, then we do not need frame number.
- //
- if ($useAnim)
- {
- if (multiframeFormat($imageType))
- {
- $useAnim = 0;
- }
- }
-
- // Put the dot in front of the image type if the image type is not an
- // empty string.
- //
- if ($imageType != "")
- {
- $imageType = "." + $imageType;
- }
-
- if ($useAnim)
- {
- // if useAnim, make sure it's not a movie format, or else
- // bad extension names will be printed out to the window.
- int $imgFormat = `getAttr "defaultRenderGlobals.imageFormat"`;
- if ($imgFormat == 21 || $imgFormat == 22 || $imgFormat == 23)
- $useAnim = 0;
- }
- if ($useAnim)
- {
- float $byf = `getAttr defaultRenderGlobals.byFrameStep`;
- if ($byf == 0.0) $byf = 0.00001;
-
- int $pad = `getAttr "defaultRenderGlobals.extensionPadding"`;
- int $f1 = `getAttr "defaultRenderGlobals.startFrame"`;
- int $f2 = `getAttr "defaultRenderGlobals.endFrame"`;
- int $numFrames = ($f2 - $f1) / $byf;
-
- // Check to see if the numbers are being modified
- if (`getAttr "defaultRenderGlobals.modifyExtension"`)
- {
- $f1 = `getAttr defaultRenderGlobals.startExtension`;
- $f2 = $f1
- + ($numFrames * `getAttr defaultRenderGlobals.byExtension`);
- }
-
- // Convert to strings
- $frame1 = $f1;
- $frame2 = $f2;
-
- // Pad the numbers
- for ($i=size($frame1); $i<$pad; $i++)
- {
- $frame1 = "0"+$frame1;
- }
- if (`getAttr "defaultRenderGlobals.periodInExt"`)
- {
- $frame1 = "."+$frame1;
- }
-
- for ($i=size($frame2); $i<$pad; $i++)
- {
- $frame2 = "0"+$frame2;
- }
- if (`getAttr "defaultRenderGlobals.periodInExt"`)
- {
- $frame2 = "."+$frame2;
- }
- }
-
- // Check for fields
-
- string $fieldExt = "";
- int $whichFields = `getAttr defaultResolution.fields`;
- int $useFields = ($whichFields != 0);
- int $useFieldExt = (`getAttr "defaultRenderGlobals.fieldExtControl"` != 1);
- int $defFieldExt = (`getAttr "defaultRenderGlobals.fieldExtControl"` == 0);
- int $useCustom = (`getAttr "defaultRenderGlobals.fieldExtControl"` == 2);
-
- // Note that I am not using a "." in front of these.
- // That's the way the code works now.
- // I think that there should be a "."
- //
- if ($useFields && $useFieldExt)
- {
- // Add fields to the file name
- if ($defFieldExt)
- {
- if ($whichFields == 1) $fieldExt = "o";
- if ($whichFields == 2) $fieldExt = "e";
- if ($whichFields == 3 || $whichFields == 4) $fieldExt = "e (o)";
- }
- else if ($useCustom)
- {
- if ($whichFields == 1)
- {
- $fieldExt = `getAttr "defaultRenderGlobals.oddFieldExt"`;
- }
- if ($whichFields == 2)
- {
- $fieldExt = `getAttr "defaultRenderGlobals.evenFieldExt"`;
- }
- if ($whichFields == 3 || $whichFields == 4)
- {
- $fieldExt = `getAttr "defaultRenderGlobals.oddFieldExt"`
- + " ("
- + `getAttr "defaultRenderGlobals.evenFieldExt"`
- + ")";
- }
- }
- }
-
- // Now put them all together to show what is going to happen
-
- int $frameBeforeExt = `getAttr "defaultRenderGlobals.putFrameBeforeExt"`;
- // 0=ext.frame, 1=frame.ext
-
- if ($frameBeforeExt == 0)
- {
- text
- -edit
- -label ($title1+$prefix+$imageType+$frame1+$fieldExt)
- exampleText1;
-
- if ($useAnim)
- {
- text
- -edit
- -label ($title2+$prefix+$imageType+$frame2+$fieldExt)
- exampleText2;
- }
- else
- {
- text -edit -label "" exampleText2;
- }
- }
- else
- {
- text
- -edit
- -label ($title1+$prefix+$frame1+$fieldExt+$imageType)
- exampleText1;
-
- if ($useAnim)
- {
- text
- -edit
- -label ($title2+$prefix+$frame2+$fieldExt+$imageType)
- exampleText2;
- }
- else
- {
- text -edit -label "" exampleText2;
- }
- }
-
- setParent $oldParent;
- }
-
- // ----------------------------------------------------------------------------
- // Code to create and update the Image File Output frame
- //
-
- proc createFileNamePrefixControl()
- {
- // Create the control
- //
- textFieldGrp
- -label "File Name Prefix"
- -changeCommand ("changeMayaSoftwareFileNamePrefix")
- mayaSoftwareFileName;
-
- // Create a scriptJob which will update the control when the value of the
- // attribute it represents is changed.
- //
- scriptJob
- -parent mayaSoftwareFileName
- -attributeChange
- "defaultRenderGlobals.imageFilePrefix"
- "updateMayaSoftwareFileNamePrefixControl";
- }
-
- global proc changeMayaSoftwareFileNamePrefix()
- {
- setParentToCommonTab();
-
- string $prefix = `textFieldGrp -query -text mayaSoftwareFileName`;
- string $prefixAttr = "defaultRenderGlobals.imageFilePrefix";
-
- if ( $prefix != "(not set; using filename)"
- && isValidFileNamePrefix($prefix))
- {
- // The user has set the prefix to something, and it is a valid name, so
- // we will set the value of the corresponding attribute.
- //
- setAttr $prefixAttr -type "string" $prefix;
- }
- else
- {
- // The user has set the prefix to an invalid value. We will refresh the
- // UI to show the current value, which has not been changed.
- //
- updateMayaSoftwareFileNamePrefixControl();
- }
- }
-
- global proc updateMayaSoftwareFileNamePrefixControl()
- //
- // Procedure Name:
- // changeFileName
- //
- // Description:
- // This procedure is called when the user changes the file
- // prefix. It sets the internal representation of the prefix
- // and then updates the example to show the changes.
- //
- {
- string $oldParent = `setParent -query`;
-
- setParentToCommonTab();
-
- string $prefixAttr = "defaultRenderGlobals.imageFilePrefix";
-
- string $prefix = `getAttr $prefixAttr`;
-
- if (size($prefix) > 0)
- {
- textFieldGrp -edit -text $prefix mayaSoftwareFileName;
- }
- else
- {
- textFieldGrp -edit -text "(not set; using filename)" mayaSoftwareFileName;
- }
-
- setParent $oldParent;
- }
-
- proc createFileNameFormatControl()
- {
- optionMenuGrp
- -label "Frame/Animation Ext"
- -changeCommand ("changeMayaSoftwareFileNameFormat")
- extMenu;
-
- menuItem -label "name (Single Frame)";
- menuItem -label "name.ext (Single Frame)";
- menuItem -label "name.#.ext" mayaSoftwareNameDotFrameDotExtension;
- menuItem -label "name.ext.#" mayaSoftwareNameDotExtensionDotFrame;
- menuItem -label "name.#" mayaSoftwareNameDotFrame;
- menuItem -label "name#.ext" mayaSoftwareFrameDotExtension;
- menuItem -label "name (Multi Frame)" mayaSoftwareMultiFrame;
- menuItem -label "name.ext (Multi Frame)"
- mayaSoftwareMultiFrameDotExtension;
-
- string $attrArray[];
-
- $attrArray[size($attrArray)] = "defaultRenderGlobals.outFormatControl";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.animation";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.periodInExt";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.putFrameBeforeExt";
- $attrArray[size($attrArray)] = "defaultRenderGlobals.imageFormat";
-
- // Now we establish scriptJobs to invoke the procedure which updates the
- // file name format control when any of the above attributes change.
- //
- int $i;
-
- for ($i = 0; $i < size($attrArray); $i++)
- {
- scriptJob
- -attributeChange
- $attrArray[$i]
- "updateMayaSoftwareFileNameFormatControl"
- -parent extMenu;
- }
- }
-
- global proc changeMayaSoftwareFileNameFormat()
- //
- // Procedure Name:
- // changeExtension
- //
- // Description:
- // This procedure is called when the user changes the format
- // of the file extension. It sets the internal representation
- // and then updates the example to show the changes.
- //
- // Note:
- // Although the user sees only one control to change the
- // extension, it actually affects more than one value.
- //
- {
- setParentToCommonTab();
-
- global string $imgExt[]; // This is the actual file extension
- global int $imgExtNum[]; // This is the corresponding internal value
-
- int $item = `optionMenuGrp -q -sl extMenu`;
- int $imageFormatNum = `getAttr defaultRenderGlobals.imageFormat`;
- int $multiframe =
- multiframeFormat(extOfImageFormat($imageFormatNum));
-
- // print ("changeExtension to "
- // + $ext
- // + " "
- // + $imgExt[$ext]
- // + "\nmultiframe "
- // + $multiframe + "\n");
-
- if ($item == 1) // "name"
- {
- // Animation off
- //
- setAttr defaultRenderGlobals.animation 0;
-
- // No image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 1;
- setAttr "defaultRenderGlobals.periodInExt" 1;
- }
- else if ($item == 2) // "name.ext"
- {
- // Animation off
- //
- setAttr defaultRenderGlobals.animation 0;
-
- if (`checkBoxGrp -q -v1 useCustomExtensionCtrl`)
- {
- // Override image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 2;
- }
- else
- {
- // Standard image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 0;
- }
- setAttr "defaultRenderGlobals.periodInExt" 1;
- }
- else if ($item == 3) // "name.#.ext"
- {
- // Animation on
- //
- setAttr defaultRenderGlobals.animation 1;
-
- if (`checkBoxGrp -q -v1 useCustomExtensionCtrl`)
- {
- // Override image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 2;
- }
- else
- {
- // Standard image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 0;
- }
- setAttr "defaultRenderGlobals.putFrameBeforeExt" 1;
- setAttr "defaultRenderGlobals.periodInExt" 1;
- }
- else if ($item == 4) // "name.ext.#"
- {
- // Animation on
- //
- setAttr defaultRenderGlobals.animation 1;
-
- if (`checkBoxGrp -q -v1 useCustomExtensionCtrl`)
- {
- // Override image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 2;
- }
- else
- {
- // Standard image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 0;
- }
- setAttr "defaultRenderGlobals.putFrameBeforeExt" 0;
- setAttr "defaultRenderGlobals.periodInExt" 1;
- }
- else if ($item == 5) // "name.#"
- {
- // Animation on
- //
- setAttr defaultRenderGlobals.animation 1;
-
- // No image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 1;
- setAttr "defaultRenderGlobals.periodInExt" 1;
- }
- else if ($item == 6) // "name#.ext"
- {
- // Animation on
- //
- setAttr defaultRenderGlobals.animation 1;
-
- if (`checkBoxGrp -q -v1 useCustomExtensionCtrl`)
- {
- // Override image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 2;
- }
- else
- {
- // Standard image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 0;
- }
- setAttr "defaultRenderGlobals.putFrameBeforeExt" 1;
- setAttr "defaultRenderGlobals.periodInExt" 0;
- }
- else if ($item == 7) // "name (Multi Frame)"
- {
- // Animation on
- //
- setAttr defaultRenderGlobals.animation 1;
-
- // No image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 1;
- setAttr "defaultRenderGlobals.periodInExt" 1;
- }
- else if ($item == 8) // "name.ext (Multi Frame)"
- {
- // Animation on
- //
- setAttr defaultRenderGlobals.animation 1;
-
- if (`checkBoxGrp -q -v1 useCustomExtensionCtrl`)
- {
- // Override image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 2;
- }
- else
- {
- // Standard image file format type
- //
- setAttr defaultRenderGlobals.outFormatControl 0;
- }
- setAttr "defaultRenderGlobals.periodInExt" 1;
- }
-
- // Update the batch render window if it exists
- //
- if (`exists updateBatchRenderWindowTitle`)
- {
- updateBatchRenderWindowTitle();
- }
- }
-
- global proc updateMayaSoftwareFileNameFormatControl()
- {
- string $oldParent = `setParent -query`;
-
- setParentToCommonTab();
-
- int $frameBeforeExt = `getAttr "defaultRenderGlobals.putFrameBeforeExt"`;
- int $useAnim = `getAttr "defaultRenderGlobals.animation"`;
- int $imageUse = `getAttr "defaultRenderGlobals.outFormatControl"`;
- int $period = `getAttr "defaultRenderGlobals.periodInExt"`;
- int $imageFormatNum = `getAttr "defaultRenderGlobals.imageFormat"`;
-
- int $multiframe =
- multiframeFormat(extOfImageFormat($imageFormatNum));
-
- int $activeMenuItem = 0;
-
- // Update Frame/Animation Ext menuItems and enable only the relevant ones.
- //
- menuItem -edit -enable (!$multiframe) mayaSoftwareNameDotFrameDotExtension;
- menuItem -edit -enable (!$multiframe) mayaSoftwareNameDotExtensionDotFrame;
- menuItem -edit -enable (!$multiframe) mayaSoftwareNameDotFrame;
- menuItem -edit -enable (!$multiframe) mayaSoftwareFrameDotExtension;
- menuItem -edit -enable $multiframe mayaSoftwareMultiFrame;
- menuItem -edit -enable $multiframe mayaSoftwareMultiFrameDotExtension;
-
- if ($multiframe)
- {
- if ($useAnim)
- {
- if ($imageUse == 1) // no extension
- {
- $activeMenuItem = 7;
- }
- else
- {
- $activeMenuItem = 8;
- }
- }
- else
- {
- if ($imageUse == 1) // no extension
- {
- $activeMenuItem = 1;
- }
- else
- {
- $activeMenuItem = 2;
- }
- }
- }
- else
- {
- if ($useAnim)
- {
- if ($imageUse == 1)
- {
- $activeMenuItem = 5;
- }
- else
- {
- if ($frameBeforeExt == 0)
- {
- $activeMenuItem = 4;
- }
- else
- {
- if ($period == 0)
- {
- $activeMenuItem = 6;
- }
- else
- {
- $activeMenuItem = 3;
- }
- }
- }
- }
- else
- {
- if ($imageUse == 1)
- {
- $activeMenuItem = 1;
- }
- else
- {
- $activeMenuItem = 2;
- }
- }
- }
-
- optionMenuGrp -edit -sl $activeMenuItem extMenu;
-
- // Also update the frame number controls to enable/disable them according
- // to whether or not they are being used.
- //
- updateMayaSoftwareFrameNumberControls();
-
- setParent $oldParent;
- }
-
- proc createUseCustomExtensionControl()
- {
- checkBoxGrp
- -numberOfCheckBoxes 1
- -label ""
- -label1 "Use Custom Extension:"
- -changeCommand "changeMayaSoftwareUseCustomExtension"
- useCustomExtensionCtrl;
-
- scriptJob
- -parent useCustomExtensionCtrl
- -attributeChange "defaultRenderGlobals.outFormatControl"
- "updateMayaSoftwareUseCustomExtensionControl";
- }
-
- global proc updateMayaSoftwareUseCustomExtensionControl()
- {
- string $oldParent = `setParent -query`;
-
- setParentToCommonTab();
-
- int $useImage = (`getAttr "defaultRenderGlobals.outFormatControl"` != 1);
-
- checkBoxGrp
- -edit
- -value1 (`getAttr "defaultRenderGlobals.outFormatControl"` == 2)
- -enable $useImage
- useCustomExtensionCtrl;
-
- setParent $oldParent;
- }
-
- global proc changeMayaSoftwareUseCustomExtension()
- {
- // TODO: Update docs
- //
- // Procedure Name:
- // changeCustomExtensionCheck
- //
- // Description:
- // This procedure is called when the user turns the custom
- // extension on or off. It sets the internal representation
- // and then updates the example to show the changes.
- //
- setParentToCommonTab();
-
- int $isOn = `checkBoxGrp -query -value1 useCustomExtensionCtrl`;
-
- if ($isOn)
- {
- setAttr defaultRenderGlobals.outFormatControl 2;
- }
- else
- {
- // We have to figure out if there should be an extension
- // at all or not.
- //
- int $item = `optionMenuGrp -query -select extMenu`;
-
- if ($item == 1 || $item == 5)
- {
- setAttr defaultRenderGlobals.outFormatControl 1;
- }
- else
- {
- setAttr defaultRenderGlobals.outFormatControl 0;
- }
- }
- }
-
- proc createCustomExtensionControl()
- {
- attrControlGrp
- -label ""
- -attribute defaultRenderGlobals.outFormatExt
- userExt;
-
- scriptJob
- -parent userExt
- -attributeChange "defaultRenderGlobals.outFormatControl"
- "updateMayaSoftwareCustomExtensionControl";
- }
-
- global proc updateMayaSoftwareCustomExtensionControl()
- {
- string $oldParent = `setParent -query`;
-
- setParentToCommonTab();
-
- // TODO: Find a better name for value1
- int $useImage = (`getAttr "defaultRenderGlobals.outFormatControl"` != 1);
- int $value1 = (`getAttr "defaultRenderGlobals.outFormatControl"` == 2);
- int $useExt = $useImage && $value1;
-
- attrControlGrp
- -edit
- -enable $useExt
- userExt;
-
- setParent $oldParent;
- }
-
- proc createCompressorControlForMac(int $item)
- {
- global string $imgExt[];
- rowLayout -adjustableColumn true -nc 4 ;
- text -l "";
- button -l "Compression..." -width 80 -enable false -c "movieCompressor -softwareOptions" renderGlobalsCompression;
- text -l "";
- text -l "";
- setParent ..;
- if($imgExt[$item] == "qt"){
- button -e -enable true renderGlobalsCompression;
- }
-
- }
-
- proc enableMacCompressorbutton(int $item)
- {
- global int $imgExtNum[];
- if(`about -mac`){
- if($imgExtNum[$item] == 22){
- button -e -enable true renderGlobalsCompression;
- }else{
- button -e -enable false renderGlobalsCompression;
- }
- }
- }
-
-
- proc createImageFormatControl()
- {
- string $parent = `setParent -query`;
-
- // These tables translate between the internal representation of the
- // image formats and the UI that is presented to the user.
- //
- // Fill up the below tables alphabetically.
- // NOTE !!!! WARNING !!!! NOTE !!!! WARNING !!!! NOTE !!!! WARNING !!!!
- // If you are changing one of the menuItem fields below or adding new ones
- // or whatever, be certain to also update the fields in the
- // 'createImageFormats()' procedure of createImageFormats.mel
- //
- // TODO: There has got to be a better way of implementing this mechanism.
-
- optionMenuGrp
- -label "Image Format"
- -changeCommand "changeMayaSoftwareImageFormat"
- imageMenu;
-
- if (`about -nt`)
- {
- menuItem -label "Alias PIX (als)"; // $imgExt[0] = "als"; $imgExtNum[0] = 6;
- menuItem -label "AVI (avi)"; // $imgExt[1] = "avi"; $imgExtNum[1] = 23;
- menuItem -label "Cineon (cin)"; // $imgExt[2] = "cin"; $imgExtNum[2] = 11;
- menuItem -label "EPS (eps)"; // $imgExt[3] = "eps"; $imgExtNum[3] = 9;
- menuItem -label "GIF (gif)"; // $imgExt[4] = "gif"; $imgExtNum[4] = 0;
- menuItem -label "JPEG (jpeg)"; // $imgExt[5] = "jpeg"; $imgExtNum[5] = 8;
- menuItem -label "Maya IFF (iff)"; // $imgExt[6] = "iff"; $imgExtNum[6] = 7;
- menuItem -label "Maya16 IFF (iff)"; // $imgExt[7] = "iff"; $imgExtNum[7] = 10;
- menuItem -label "Quantel (yuv)"; // $imgExt[8] = "yuv"; $imgExtNum[8] = 12;
- menuItem -label "RLA (rla)"; // $imgExt[9] = "rla"; $imgExtNum[9] = 2;
- menuItem -label "SGI (sgi)"; // $imgExt[10] = "sgi"; $imgExtNum[10] = 5;
- menuItem -label "SGI16 (sgi)"; // $imgExt[11] = "sgi"; $imgExtNum[11] = 13;
- menuItem -label "SoftImage (pic)"; // $imgExt[12] = "pic"; $imgExtNum[12] = 1;
- menuItem -label "Targa (tga)"; // $imgExt[13] = "tga"; $imgExtNum[13] = 19;
- menuItem -label "Tiff (tif)"; // $imgExt[14] = "tif"; $imgExtNum[14] = 3;
- menuItem -label "Tiff16 (tif)"; // $imgExt[15] = "tif"; $imgExtNum[15] = 4;
- menuItem -label "Windows Bitmap (bmp)"; // $imgExt[16] = "bmp"; $imgExtNum[16] = 20;
- }
- else if (`about -irix`)
- {
- menuItem -label "Alias PIX (als)"; // $imgExt[0] = "als"; $imgExtNum[0] = 6;
- menuItem -label "AVI (avi)"; // $imgExt[1] = "avi"; $imgExtNum[1] = 23;
- menuItem -label "Cineon (cin)"; // $imgExt[2] = "cin"; $imgExtNum[2] = 11;
- menuItem -label "EPS (eps)"; // $imgExt[3] = "eps"; $imgExtNum[3] = 9;
- menuItem -label "GIF (gif)"; // $imgExt[4] = "gif"; $imgExtNum[4] = 0;
- menuItem -label "JPEG (jpeg)"; // $imgExt[5] = "jpeg"; $imgExtNum[5] = 8;
- menuItem -label "Maya IFF (iff)"; // $imgExt[6] = "iff"; $imgExtNum[6] = 7;
- menuItem -label "Maya16 IFF (iff)"; // $imgExt[7] = "iff"; $imgExtNum[7] = 10;
- menuItem -label "Quantel (yuv)"; // $imgExt[8] = "yuv"; $imgExtNum[8] = 12;
- menuItem -label "Quicktime (qt)"; // $imgExt[9] = "qt"; $imgExtNum[9] = 22;
- menuItem -label "RLA (rla)"; // $imgExt[10] = "rla"; $imgExtNum[10] = 2;
- menuItem -label "SGI (sgi)"; // $imgExt[11] = "sgi"; $imgExtNum[11] = 5;
- menuItem -label "SGI16 (sgi)"; // $imgExt[12] = "sgi"; $imgExtNum[12] = 13;
- menuItem -label "SGI Movie (mv)"; // $imgExt[13] = "mv"; $imgExtNum[13] = 21;
- menuItem -label "SoftImage (pic)"; // $imgExt[14] = "pic"; $imgExtNum[14] = 1;
- menuItem -label "Targa (tga)"; // $imgExt[15] = "tga"; $imgExtNum[15] = 19;
- menuItem -label "Tiff (tif)"; // $imgExt[16] = "tif"; $imgExtNum[16] = 3;
- menuItem -label "Tiff16 (tif)"; // $imgExt[17] = "tif"; $imgExtNum[17] = 4;
- menuItem -label "Windows Bitmap (bmp)"; // $imgExt[18] = "bmp"; $imgExtNum[18] = 20;
- }
- else if (`about -linux`)
- {
- menuItem -label "Alias PIX (als)"; // $imgExt[0] = "als"; $imgExtNum[0] = 6;
- menuItem -label "Cineon (cin)"; // $imgExt[1] = "cin"; $imgExtNum[1] = 11;
- menuItem -label "EPS (eps)"; // $imgExt[2] = "eps"; $imgExtNum[2] = 9;
- menuItem -label "GIF (gif)"; // $imgExt[3] = "gif"; $imgExtNum[3] = 0;
- menuItem -label "JPEG (jpeg)"; // $imgExt[4] = "jpeg"; $imgExtNum[4] = 8;
- menuItem -label "Maya IFF (iff)"; // $imgExt[5] = "iff"; $imgExtNum[5] = 7;
- menuItem -label "Maya16 IFF (iff)"; // $imgExt[6] = "iff"; $imgExtNum[6] = 10;
- menuItem -label "Quantel (yuv)"; // $imgExt[7] = "yuv"; $imgExtNum[7] = 12;
- menuItem -label "RLA (rla)"; // $imgExt[8] = "rla"; $imgExtNum[8] = 2;
- menuItem -label "SGI (sgi)"; // $imgExt[9] = "sgi"; $imgExtNum[9] = 5;
- menuItem -label "SGI16 (sgi)"; // $imgExt[10] = "sgi"; $imgExtNum[10] = 13;
- menuItem -label "SoftImage (pic)"; // $imgExt[11] = "pic"; $imgExtNum[11] = 1;
- menuItem -label "Targa (tga)"; // $imgExt[12] = "tga"; $imgExtNum[12] = 19;
- menuItem -label "Tiff (tif)"; // $imgExt[13] = "tif"; $imgExtNum[13] = 3;
- menuItem -label "Tiff16 (tif)"; // $imgExt[14] = "tif"; $imgExtNum[14] = 4;
- menuItem -label "Windows Bitmap (bmp)"; // $imgExt[15] = "bmp"; $imgExtNum[15] = 20;
- }
- else if (`about -mac`)
- {
- menuItem -label "JPEG (jpeg)"; // $imgExt[0] = "jpeg"; $imgExtNum[0] = 8;
- menuItem -label "Maya IFF (iff)"; // $imgExt[1] = "iff"; $imgExtNum[1] = 7;
- menuItem -label "Maya16 IFF (iff)"; // $imgExt[2] = "iff"; $imgExtNum[2] = 10;
- menuItem -label "MacPaint (pntg)"; // $imgExt[3] = "pntg"; $imgExtNum[3] = 30;
- menuItem -label "Photoshop (ps)"; // $imgExt[4] = "ps"; $imgExtNum[4] = 31;
- menuItem -label "PNG (png)"; // $imgExt[5] = "png"; $imgExtNum[5] = 32;
- menuItem -label "QuickDraw (pict)"; // $imgExt[6] = "pict"; $imgExtNum[6] = 33;
- menuItem -label "Quicktime Movie (qt)"; // $imgExt[7] = "qt"; $imgExtNum[7] = 22;
- menuItem -label "Quicktime Image (qtif)";// $imgExt[8] = "qtif"; $imgExtNum[8] = 34;
- menuItem -label "Silicon Graphics (sgi)";// $imgExt[9] = "sgi"; $imgExtNum[9] = 5;
- menuItem -label "Targa (tga)"; // $imgExt[10] = "tga"; $imgExtNum[10] = 19;
- menuItem -label "Tiff (tif)"; // $imgExt[11] = "tif"; $imgExtNum[11] = 3;
- menuItem -label "Windows Bitmap (bmp)"; // $imgExt[12] = "bmp"; $imgExtNum[12] = 20;
- }
- else
- {
- warning "Unsupported platform in unifiedRenderGlobalsWindow.mel";
- }
-
- scriptJob
- -parent $parent
- -attributeChange
- "defaultRenderGlobals.imageFormat"
- "updateMayaSoftwareImageFormatControl";
- }
-
- global proc updateMayaSoftwareImageFormatControl()
- {
- string $oldParent = `setParent -query`;
-
- global string $imgExt[]; // This is the actual file extension
- global int $imgExtNum[]; // This is the corresponding internal value
-
- int $imageNum = `getAttr "defaultRenderGlobals.imageFormat"`;
-
- for ($i=0; $i < size($imgExtNum); ++$i)
- {
- if ($imageNum == $imgExtNum[$i])
- {
- optionMenuGrp -edit -sl ($i+1) imageMenu;
- enableMacCompressorbutton($i);
- break;
- }
- }
-
- setParent $oldParent;
- }
-
- global proc changeMayaSoftwareImageFormat()
- {
- //
- // Procedure Name:
- // changeImageFormat
- //
- // Description:
- // This procedure is called when the user changes the type of
- // image that will be written out. It sets the internal
- // representation and then updates the example to show the changes.
- //
- setParentToCommonTab();
-
- global string $imgExt[]; // This is the actual file extension
- global int $imgExtNum[]; // This is the corresponding internal value
-
- int $item = `optionMenuGrp -q -sl imageMenu` - 1;
- setAttr defaultRenderGlobals.imageFormat $imgExtNum[$item];
-
- enableMacCompressorbutton($item);
-
-
- // Check if the image format is IFF.
- //
- // Note: there are two IFF image types. One for 8 bit images
- // and one for 16 bit images. They both have an imgExt of iff.
-
- if ($imgExt[$item] != "iff")
- {
- int $useBlur = `getAttr defaultRenderGlobals.motionBlur`;
- int $blur2d = (`getAttr defaultRenderGlobals.motionBlurType` == 0);
- int $keepMotionVector = (`getAttr defaultRenderGlobals.keepMotionVector` == 1);
- if ($useBlur && $blur2d && $keepMotionVector)
- {
- warning
- ("Non-IFF image formats are not supported when writing"+
- " 2D motion vectors; setting image format to IFF");
-
- // Set globals imageFormat to Maya IFF
- setAttr defaultRenderGlobals.imageFormat 7;
- }
- }
-
- $item = `optionMenuGrp -q -sl imageMenu` - 1;
- int $multiframe = multiframeFormat($imgExt[$item]);
-
- if ($multiframe)
- {
- setAttr defaultRenderGlobals.animation 1;
- }
-
- // Update the batch render window if it exists.
- if (`exists updateBatchRenderWindowTitle`)
- {
- updateBatchRenderWindowTitle();
- }
- }
-
- proc createCameraControl()
- {
- //Note: not updating if changed elsewhere
- //
- optionMenuGrp
- -label "Camera"
- -changeCommand changeMayaSoftwareCamera
- mayaSoftwareCameraMenu;
- }
-
- global proc updateMayaSoftwareCameraControl()
- {
- string $oldParent = `setParent -query`;
-
- setParentToCommonTab();
-
- // This is a fix to get around the optionMenuGrp bug (#81337)
- string $fullName = `setParent "mayaSoftwareCameraMenu"`;
- string $menuName = ($fullName+"|OptionMenu");
- setParent -m $menuName;
-
- string $allCameras[] = `ls -cameras`;
- string $parents[];
- int $i;
- int $numRenderable = 0;
- string $cmd;
-
- //
- // First remove any existing menuItems; we're gonna rebuild the menu
- // from scratch each time.
-
- int $numOldMenuItems = `optionMenuGrp -q -ni mayaSoftwareCameraMenu`;
- string $oldMenuItems[] = `optionMenuGrp -q -ill mayaSoftwareCameraMenu`;
-
- for ($i = 0; $i < $numOldMenuItems; $i++)
- {
- deleteUI $oldMenuItems[$i];
- }
-
- // Run through the list of all of the cameras and build a
- // optionMenu of them that the user uses to select the
- // renderable camera.
- //
- // First count how many renderable cameras exist
- //
- for ($i = 0; $i < size($allCameras); $i++)
- {
- if (`getAttr ($allCameras[$i] + ".renderable")`)
- {
- $numRenderable++;
- }
- }
-
- int $firstRenderable = 0;
- for ($i = 0; $i < size($allCameras); $i++)
- {
- $parents = `listRelatives -path -parent $allCameras[$i]`;
- string $menuItem = `menuItem -label $parents[0]`;
- // Use the first renderable camera
- if (`getAttr ($allCameras[$i] + ".renderable")`)
- {
- $firstRenderable++;
- if ($firstRenderable == 1)
- {
- // Selected Camera -----------------------------------------
- optionMenuGrp -edit -sl ($i+1) mayaSoftwareCameraMenu;
- }
- if ($numRenderable > 1)
- {
- string $camLabel = $parents[0] + " (Renderable)";
- menuItem -edit -label $camLabel $menuItem;
- }
- }
- }
-
- setParent $oldParent;
- }
-
- global proc changeMayaSoftwareCamera()
- {
- //
- // Procedure Name:
- // changeMayaSoftwareCamera
- //
- // Description:
- // This procedure is called when the user changes the camera
- // that will be rendered.
- // It updates the controls for the new camera
- //
- setParentToCommonTab();
-
- //
- // First count how many renderable cameras exist
- //
- string $allCameras[] = `ls -cameras`;
-
- int $numRenderable = 0;
-
- for ($i = 0; $i < size($allCameras); $i++)
- {
- if (`getAttr ($allCameras[$i] + ".renderable")`)
- {
- $numRenderable++;
- }
- }
-
- int $camIndex = `optionMenuGrp -query -select mayaSoftwareCameraMenu` - 1;
-
- if ($numRenderable < 2)
- {
- for ($i = 0; $i < size($allCameras); $i++)
- {
- if ($i == $camIndex)
- {
- setAttr ($allCameras[$i] + ".renderable") 1;
- }
- else
- {
- setAttr ($allCameras[$i] + ".renderable") 0;
- }
- }
- }
-
- // Connect the channel controls to the new camera.
- //
- string $whichCamera = $allCameras[$camIndex];
- attrControlGrp -edit -attribute ($whichCamera + ".image") rgbChannel;
- attrControlGrp -edit -attribute ($whichCamera + ".mask") alphaChannel;
- attrControlGrp -edit -attribute ($whichCamera + ".depth") depthChannel;
-
- // Fix for 160069. The mental ray renderer and the Maya renderer
- // use the same renderable camera, so the mental ray render globals and
- // the Maya render globals must be kept in sync when the renderable camera
- // changes. The following code causes the attribute editor to be
- // refreshed, just in case it contains the mental ray render globals.
- //
- global string $gAEFocusNode;
- updateAE($gAEFocusNode);
- }
-
- global proc updateMayaSoftwareFrameNumberControls()
- {
- int $useAnim = `getAttr "defaultRenderGlobals.animation"`;
- int $useCustomExt = `getAttr "defaultRenderGlobals.modifyExtension"`;
- int $imageFormatNum = `getAttr "defaultRenderGlobals.imageFormat"`;
- int $multiframe =
- multiframeFormat(extOfImageFormat($imageFormatNum));
-
- attrControlGrp
- -edit
- -enable $useAnim
- startFrameCtrl;
- attrControlGrp
- -edit
- -enable $useAnim
- endFrameCtrl;
- attrControlGrp
- -edit
- -enable $useAnim
- byFrameStepCtrl;
- attrControlGrp
- -edit
- -enable ($useAnim && !$multiframe)
- extensionPaddingCtrl;
- attrControlGrp
- -edit
- -enable ($useAnim && !$multiframe)
- modifyExtensionCtrl;
- attrControlGrp
- -edit
- -enable ($useAnim && $useCustomExt && !$multiframe)
- startExtensionCtrl;
- attrControlGrp
- -edit
- -enable ($useAnim && $useCustomExt && !$multiframe)
- byExtensionCtrl;
- }
-
- proc createCommonImageFile()
- //
- // Procedure Name:
- // createCommonImageFile
- //
- // Description:
- // Creates the UI in the "Image File Output" expand/collapse section.
- // This section is always created so is treated differently
- // then the sections created when the tab is expanded.
- //
- {
- string $parent = `setParent -query`;
-
- setUITemplate -pushTemplate attributeEditorTemplate;
-
- global string $imgExt[];
-
- if (size($imgExt) == 0)
- {
- // If the file format array has not been initialized yet, do so.
- // This routine may be called in dynPaintMenus.mel during the
- // file save for PFX canvas images.
- //
- createImageFormats();
- }
-
- columnLayout -adjustableColumn true;
-
- createFileNamePrefixControl();
- createFileNameFormatControl();
- createImageFormatControl();
- if(`about -mac`){
- int $item = `optionMenuGrp -q -sl imageMenu` - 1;
- createCompressorControlForMac($item);
- }
-
- separator;
-
- // Frame numbers ------------------------------------------------
-
- attrControlGrp
- -attribute defaultRenderGlobals.startFrame
- -label "Start Frame"
- -hideMapButton true
- startFrameCtrl;
- attrControlGrp
- -attribute defaultRenderGlobals.endFrame
- -label "End Frame"
- -hideMapButton true
- endFrameCtrl;
- attrControlGrp
- -attribute defaultRenderGlobals.byFrameStep
- -label "By Frame"
- -hideMapButton true
- byFrameStepCtrl;
- attrControlGrp
- -attribute defaultRenderGlobals.extensionPadding
- -label "Frame Padding"
- -hideMapButton true
- extensionPaddingCtrl;
-
- separator;
-
- // Renderable Objects ------------------------------------------------
-
- attrEnumOptionMenuGrp
- -label "Renderable Objects"
- -attribute "defaultRenderGlobals.renderAll"
- -enumeratedItem 1 "Render All"
- -enumeratedItem 0 "Render Active";
-
- // Cameras ------------------------------------------------
-
- createCameraControl();
- updateMayaSoftwareCameraControl();
-
- // Channels ------------------------------------------------
-
- //
- string $currentCamera = `optionMenuGrp -q -v mayaSoftwareCameraMenu`;
- //
- // Remove the substring " (Renderable)" from the string
- // $currentCamera if there is any.
- //
- $currentCamera = `substitute " .*" $currentCamera ""`;
- string $camShapes[] = `listRelatives -path -shapes $currentCamera`;
- $currentCamera = $camShapes[0];
-
- attrControlGrp
- -label "RGB Channel (Color)"
- -attribute ($currentCamera + ".image")
- rgbChannel;
- attrControlGrp
- -label "Alpha Channel (Mask)"
- -attribute ($currentCamera + ".mask")
- alphaChannel;
- attrControlGrp
- -label "Depth Channel (Z Depth)"
- -attribute ($currentCamera + ".depth")
- depthChannel;
-
- // Custom Extension ----------------------------------------
-
- frameLayout
- -label "Custom Extension"
- -collapsable true
- -collapse true;
-
- columnLayout;
-
- createUseCustomExtensionControl();
- createCustomExtensionControl();
-
- setParent ..;
- setParent ..;
-
- // Renumber ------------------------------------------------
-
- frameLayout
- -label "Renumber Frames"
- -collapsable true
- -collapse true;
-
- columnLayout;
-
- attrControlGrp
- -attribute defaultRenderGlobals.modifyExtension
- -changeCommand "updateMayaSoftwareFrameNumberControls"
- -label "Renumber Frames Using:"
- modifyExtensionCtrl;
- attrControlGrp
- -attribute defaultRenderGlobals.startExtension
- -enable (`getAttr defaultRenderGlobals.modifyExtension`)
- -hideMapButton true
- -label "Start Number"
- startExtensionCtrl;
- attrControlGrp
- -attribute defaultRenderGlobals.byExtension
- -enable (`getAttr defaultRenderGlobals.modifyExtension`)
- -hideMapButton true
- -label "By Frame"
- byExtensionCtrl;
-
- setParent ..;
- setParent ..;
-
- setParent $parent;
- setUITemplate -popTemplate;
-
- // Perform an initial update of the UI created above, so that controls
- // which are not directly connected to attributes are properly initialized.
- //
- updateMayaSoftwareFileNamePrefixControl();
- updateMayaSoftwareFileNameFormatControl();
- updateMayaSoftwareImageFormatControl();
- updateMayaSoftwareUseCustomExtensionControl();
- updateMayaSoftwareCustomExtensionControl();
- }
-
- // ----------------------------------------------------------------------------
- // Code to create and update the Resolution frame
- //
-
- global proc createCommonResolution()
- //
- // Procedure Name:
- // createCommonResolution
- //
- // Description:
- // Creates the UI in the "Resolution" expand/collapse section.
- //
- {
- //
- // Make sure the list of predefined resolutions has been read in.
- //
- global string $gImageFormatData[];
- global string $gUserImageFormatData[];
-
- if (size($gImageFormatData) == 0)
- {
- eval("source imageFormats");
- }
-
- int $isMayaEvalVersion = `about -ev`;
- global string $gPLEImageFormatData[];
- if ($isMayaEvalVersion)
- {
- $gImageFormatData = $gPLEImageFormatData;
- }
-
- if (exists("userImageFormats.mel") && size($gUserImageFormatData) == 0)
- {
- // Yes, we need the eval here, to avoid doing the source
- // until we know whether the file actually exists
- eval("source userImageFormats");
- }
-
- setUITemplate -pushTemplate attributeEditorTemplate;
-
- // If the UI is created already then just update the attribute values.
- if (`columnLayout -exists rgResolutionLayout`)
- {
- updateMayaSoftwareResolution();
- return;
- }
-
- columnLayout -adjustableColumn true rgResolutionLayout;
- int $resItem;
- int $numResolutionPresets = size($gImageFormatData);
- int $numUserResolutionPresets = size($gUserImageFormatData);
- string $allResNodes[] = `ls -type resolution`;
- int $numResolutionNodePresets = size($allResNodes) - 1;
- int $numTokens;
- string $tokens[];
- string $niceName;
-
- optionMenuGrp
- -label "Presets"
- -changeCommand "changeMayaSoftwareResolution()"
- resolutionMenu;
-
- menuItem -label "Custom";
- for ($resItem = 0; $resItem < $numResolutionPresets; $resItem++)
- {
- string $item = $gImageFormatData[$resItem];
- $numTokens = tokenize($item, $tokens);
-
- // Change any underscore into a space;
- // some names may have up to 2 underscores in them,
- // so we do this twice.
- //
- $niceName = `substitute "_" $tokens[0] " "`;
- $niceName = `substitute "_" $niceName " "`;
- menuItem -label $niceName;
- }
- for ($resItem = 0; $resItem < $numUserResolutionPresets; $resItem++)
- {
- string $item = $gUserImageFormatData[$resItem];
- $numTokens = tokenize($item, $tokens);
-
- // Change any underscore into a space;
- // some names may have up to 2 underscores in them,
- // so we do this twice.
- //
- $niceName = `substitute "_" $tokens[0] " "`;
- $niceName = `substitute "_" $niceName " "`;
- menuItem -label $niceName;
- }
- for ($resItem = 0; $resItem < $numResolutionNodePresets; $resItem++)
- {
- menuItem -label $allResNodes[$resItem + 1];
- }
-
- separator;
-
- checkBoxGrp -numberOfCheckBoxes 1
- -label1 "Maintain Width/Height Ratio"
- -changeCommand
- ("setAttr defaultResolution.aspectLock #1;"
- + "checkMayaSoftwareAspectLock \"defaultResolution\";"
- + "updateMayaSoftwareResolution")
- aspectLockCheck;
-
- intFieldGrp -label "Width"
- -changeCommand "changeMayaSoftwareAspectLockWidth"
- mayaSoftwareResWidth;
- intFieldGrp -label "Height"
- -changeCommand "changeMayaSoftwareAspectLockHeight"
- mayaSoftwareResHeight;
-
- separator;
-
- checkBoxGrp -numberOfCheckBoxes 1
- -label1 "Lock Device Aspect Ratio"
- -changeCommand
- ("setAttr defaultResolution.lockDeviceAspectRatio #1;"
- + "changeMayaSoftwareAspectLockWidth")
- ratioLockCheck;
-
- floatFieldGrp -label "Device Aspect Ratio"
- -changeCommand "updateMayaSoftwareDeviceAspectRatio"
- resRatio;
-
- floatFieldGrp -label "Pixel Aspect Ratio"
- -changeCommand "adjustMayaSoftwareDeviceAspect \"defaultResolution\""
- pixRatio;
-
- setParent ..;
- setUITemplate -popTemplate;
-
- // Make sure the values are right
- updateMayaSoftwareResolution();
- }
-
- global proc updateMayaSoftwareResolution()
- //
- // Procedure Name:
- // updateResolution
- //
- // Description:
- // Gets the real values from the nodes and sets the UI based
- // on these values. This procedure updates all of the resolution
- // values.
- //
- {
- setParentToCommonTab();
-
- int $width = `getAttr defaultResolution.width`;
- int $height = `getAttr defaultResolution.height`;
- float $aspect = `getAttr defaultResolution.deviceAspectRatio`;
- int $resItem;
- int $whichRes = 1; // use "Custom" if no match is found
- string $allResNodes[] = `ls -type resolution`;
-
- global string $gImageFormatData[];
- global string $gUserImageFormatData[];
- int $numResolutionPresets = size($gImageFormatData);
- int $numUserResolutionPresets = size($gUserImageFormatData);
- int $numResolutionNodePresets = size($allResNodes) - 1;
- int $resWidth;
- int $resHeight;
- float $resAspect;
- int $numTokens;
- string $tokens[];
-
- for ($resItem = 0; $resItem < $numResolutionPresets; $resItem++)
- {
- string $item = $gImageFormatData[$resItem];
- $numTokens = tokenize($item, $tokens);
- if ($numTokens == 4)
- {
- $resWidth = $tokens[1];
- $resHeight = $tokens[2];
- $resAspect = $tokens[3];
- if ($width == $resWidth && $height == $resHeight
- && abs($aspect - $resAspect) < 0.001)
- {
- // We add _2_ to $resItem below: 1 because we're
- // skipping the first item (Custom) in the list, and 1
- // because the optionMenu items are numbered starting at 1,
- // but our list in $gImageFormatData is indexed starting at 0.
- $whichRes = $resItem + 2;
- break;
- }
- }
- else
- {
- warning(
- "Found invalid image format description: \""
- + $item
- + "\" in imageFormats.mel");
- }
- }
-
- // If no match was found in the built-in resolutions,
- // check out the user-defined ones
- //
- if ($whichRes == 1)
- {
- for ($resItem = 0; $resItem < $numUserResolutionPresets; $resItem++)
- {
- string $item = $gUserImageFormatData[$resItem];
- $numTokens = tokenize($item, $tokens);
- if ($numTokens == 4)
- {
- $resWidth = $tokens[1];
- $resHeight = $tokens[2];
- $resAspect = $tokens[3];
- if ($width == $resWidth && $height == $resHeight
- && abs($aspect - $resAspect) < 0.001)
- {
- $whichRes = $numResolutionPresets + $resItem + 2;
- break;
- }
- }
- else
- {
- warning(
- "Found invalid image format description: \""
- + $item
- + "\" in userImageFormats.mel");
- }
- }
- }
-
- // If no match was found in the user-defined resolutions,
- // see if there are any 'extra' resolution nodes in the scene.
- //
- if ($whichRes == 1)
- {
- for ($resItem = 0; $resItem < $numResolutionNodePresets; $resItem++)
- {
- // We assume the 0th item in the list of resolution nodes is
- // the default one, which is created implicitly...
- //
- string $resNodeName = $allResNodes[$resItem + 1];
-
- $resWidth = `getAttr ($resNodeName + ".width")`;
- $resHeight = `getAttr ($resNodeName + ".height")`;
- $resAspect = `getAttr ($resNodeName + ".deviceAspectRatio")`;
-
- if ($width == $resWidth && $height == $resHeight
- && abs($aspect - $resAspect) < 0.001)
- {
- // We add _2_ to $resItem below: 1 because we're
- // skipping the first item (Custom) in the list, and 1
- // because the optionMenu items are numbered starting at 1,
- // but our list in $gImageFormatData is indexed starting at 0.
- //
- $whichRes = $numResolutionPresets
- + $numUserResolutionPresets + $resItem + 2;
- break;
- }
- }
- }
- optionMenuGrp -edit -sl $whichRes resolutionMenu;
-
- checkBoxGrp -edit -v1 `getAttr defaultResolution.aspectLock` aspectLockCheck;
- intFieldGrp -edit -v1 $width mayaSoftwareResWidth;
- intFieldGrp -edit -v1 $height mayaSoftwareResHeight;
- floatFieldGrp -edit -v1 $aspect resRatio;
- adjustMayaSoftwarePixelAspect "defaultResolution";
- checkBoxGrp -edit -v1 `getAttr defaultResolution.lockDeviceAspectRatio` ratioLockCheck;
- }
-
- global proc changeMayaSoftwareResolution()
- //
- // Procedure Name:
- // changeResolution
- //
- // Description:
- // This procedure is called when the user selects a different
- // resolution. It sets the internal representation
- // and then updates the example to show the changes.
- //
- {
- setParentToCommonTab();
-
- global string $gImageFormatData[];
- global string $gUserImageFormatData[];
- int $numResolutionPresets = size($gImageFormatData);
- int $numUserResolutionPresets = size($gUserImageFormatData);
- string $allResNodes[] = `ls -type resolution`;
- int $numResolutionNodePresets = size($allResNodes) - 1;
- string $tokens[];
- int $resItem = `optionMenuGrp -q -sl resolutionMenu`;
- int $resWidth;
- int $resHeight;
- float $resAspect;
- string $item;
-
- // Item #1 is Custom, which doesn't change the fields
- // We subtract _2_ from $resItem below: 1 because we're
- // skipping the first item (Custom) in the list, and 1
- // because the optionMenu items are numbered starting at 1,
- // but our list in $gImageFormatData is indexed starting at 0.
- //
- if ($resItem > 1)
- {
- if ($resItem > ($numResolutionPresets + 1))
- {
- if ($resItem
- > ($numResolutionPresets + $numUserResolutionPresets + 1))
- {
- // It's one of the user-defined resolution nodes' presets
- string $resNodeName = $allResNodes[$resItem
- - $numResolutionPresets
- - $numUserResolutionPresets
- - 1];
- $resWidth = `getAttr ($resNodeName + ".width")`;
- $resHeight = `getAttr ($resNodeName + ".height")`;
- $resAspect = `getAttr ($resNodeName + ".deviceAspectRatio")`;
- }
- else
- {
- // It's one of the user-defined resolution presets
- $item = $gUserImageFormatData[$resItem
- - $numResolutionPresets - 2];
- int $numTokens = tokenize($item, $tokens);
- $resWidth = $tokens[1];
- $resHeight = $tokens[2];
- $resAspect = $tokens[3];
- }
- }
- else
- {
- // It's one of the built-in resolution presets
- $item = $gImageFormatData[$resItem - 2];
- int $numTokens = tokenize($item, $tokens);
- $resWidth = $tokens[1];
- $resHeight = $tokens[2];
- $resAspect = $tokens[3];
- }
- setAttr "defaultResolution.width" $resWidth;
- setAttr "defaultResolution.height" $resHeight;
- setAttr "defaultResolution.deviceAspectRatio" $resAspect;
- setAttr "defaultResolution.lockDeviceAspectRatio" 1;
-
- // Set the proper field ordering if PAL or NTSC.
- if (`getAttr defaultResolution.height` == 576) // PAL
- {
- setAttr "defaultResolution.oddFieldFirst" 0;
- if (`columnLayout -exists rgFieldLayout`)
- {
- if (`exists updateFieldOptions`)
- {
- updateFieldOptions();
- }
- }
- }
- else if (`getAttr defaultResolution.height` == 486) // NTSC
- {
- setAttr "defaultResolution.oddFieldFirst" 1;
- if (`columnLayout -exists rgFieldLayout`)
- {
- if (`exists updateFieldOptions`)
- {
- updateFieldOptions();
- }
- }
- }
- }
-
- updateMayaSoftwareResolution();
- }
-
- global proc checkMayaSoftwareAspectLockWidth(string $nodeName)
- {
- float $deviceAspect;
-
- if (`getAttr ($nodeName + ".aspectLock")`)
- {
- int $value = `getAttr ($nodeName + ".width")`;
-
- float $aspect = `getAttr ($nodeName + ".pixelAspect")`;
-
- if ($aspect > 0.0)
- {
- int $rez = $aspect * $value;
- int $oldrez = `getAttr ($nodeName + ".height")`;
- if ($rez - $oldrez > 1 || $oldrez - $rez > 1)
- {
- setAttr ($nodeName + ".height") $rez;
- }
- }
- else
- {
- checkMayaSoftwareAspectLock $nodeName;
- }
- }
-
- if (`getAttr ($nodeName + ".lockDeviceAspectRatio")` == 0)
- {
- $deviceAspect = `getAttr ($nodeName + ".width")`;
- $deviceAspect = $deviceAspect / `getAttr ($nodeName + ".height")`;
- setAttr ($nodeName + ".deviceAspectRatio") $deviceAspect;
- }
- }
-
- global proc checkMayaSoftwareAspectLockHeight(string $nodeName)
- {
- float $deviceAspect;
-
- if (`getAttr ($nodeName + ".aspectLock")`)
- {
- int $value = `getAttr ($nodeName + ".height")`;
-
- float $aspect = `getAttr ($nodeName + ".pixelAspect")`;
-
- if ($aspect > 0.0)
- {
- int $rez = $value / $aspect;
- int $oldrez = `getAttr ($nodeName + ".width")`;
- if ($rez - $oldrez > 1 || $oldrez - $rez > 1)
- {
- setAttr ($nodeName + ".width") $rez;
- }
- }
- else
- {
- checkMayaSoftwareAspectLock $nodeName;
- }
- }
-
- if (`getAttr ($nodeName + ".lockDeviceAspectRatio")` == 0)
- {
- $deviceAspect = `getAttr ($nodeName + ".width")`;
- $deviceAspect = $deviceAspect / `getAttr ($nodeName + ".height")`;
- setAttr ($nodeName + ".deviceAspectRatio") $deviceAspect;
- }
- }
-
- global proc checkMayaSoftwareAspectLock(string $nodeName)
- {
- int $lockOn = `getAttr ($nodeName + ".aspectLock")`;
-
- if ($lockOn)
- {
- float $h = `getAttr ($nodeName + ".height")`;
- float $w = `getAttr ($nodeName + ".width")`;
- float $aspect = $h / $w;
- setAttr ($nodeName + ".pixelAspect") $aspect;
- }
- else
- {
- setAttr ($nodeName + ".pixelAspect") 0.0;
- }
- }
-
- global proc changeMayaSoftwareAspectLockWidth()
- //
- // Procedure Name:
- // changeAspectLockWidth
- //
- // Description:
- // This procedure is called when the user changes the
- // resolution width. It sets the internal representation
- // then looks at the ratio lock etc and changes any other
- // values that rely on it.
- //
- {
- setParentToCommonTab();
-
- int $requestedWidth = `intFieldGrp -q -v1 mayaSoftwareResWidth`;
- int $isMayaEvalVersion = `about -ev`;
- int $kPLEMaxX = 1024;
- int $kPLEMaxY = 768;
- if ($isMayaEvalVersion)
- {
- if ($requestedWidth > $kPLEMaxX)
- {
- warning("Image resolution is limited to "+$kPLEMaxX+"x"+$kPLEMaxY+" pixels for the Maya Personal Learning Edition");
- $requestedWidth = $kPLEMaxX;
- }
- if (`getAttr defaultResolution.aspectLock`)
- {
- float $aspect = `getAttr defaultResolution.pixelAspect`;
- if ($aspect > 0.0)
- {
- int $rez = $aspect * $requestedWidth;
- int $oldrez = `getAttr defaultResolution.height`;
- if ($rez <= $kPLEMaxY)
- {
- if ($rez - $oldrez > 1 || $oldrez - $rez > 1)
- {
- setAttr defaultResolution.height $rez;
- }
- }
- else
- {
- intFieldGrp -e -v1 $kPLEMaxY mayaSoftwareResHeight;
- changeMayaSoftwareAspectLockHeight;
- return;
- }
- }
- }
- }
-
- if ($requestedWidth < 2)
- {
- warning "Width must be at least 2 pixels";
- $requestedWidth = 2;
- }
-
- setAttr defaultResolution.width $requestedWidth;
- optionMenuGrp -edit -sl 1 resolutionMenu;
- checkMayaSoftwareAspectLockWidth "defaultResolution";
-
- // Update the values
- updateMayaSoftwareResolution();
- }
-
- global proc changeMayaSoftwareAspectLockHeight()
- //
- // Procedure Name:
- // changeAspectLockHeight
- //
- // Description:
- // This procedure is called when the user changes the
- // resolution width. It sets the internal representation
- // then looks at the ratio lock etc and changes any other
- // values that rely on it.
- //
- {
- setParentToCommonTab();
-
- int $requestedHeight = `intFieldGrp -q -v1 mayaSoftwareResHeight`;
- int $isMayaEvalVersion = `about -ev`;
- int $kPLEMaxX = 1024;
- int $kPLEMaxY = 768;
- if ($isMayaEvalVersion)
- {
- if ($requestedHeight > $kPLEMaxY)
- {
- warning("Image resolution is limited to "+$kPLEMaxX+"x"+$kPLEMaxY+" pixels for the Maya Personal Learning Edition");
- $requestedHeight = $kPLEMaxY;
- }
- if (`getAttr defaultResolution.aspectLock`)
- {
- float $aspect = `getAttr defaultResolution.pixelAspect`;
- if ($aspect > 0.0)
- {
- int $rez = $requestedHeight / $aspect;
- int $oldrez = `getAttr defaultResolution.width`;
- if ($rez <= $kPLEMaxX)
- {
- if ($rez - $oldrez > 1 || $oldrez - $rez > 1)
- {
- setAttr defaultResolution.width $rez;
- }
- }
- else
- {
- intFieldGrp -e -v1 $kPLEMaxX mayaSoftwareResWidth;
- changeMayaSoftwareAspectLockWidth;
- return;
- }
- }
- }
- }
-
- if ($requestedHeight < 2)
- {
- warning "Height must be at least 2 pixels";
- $requestedHeight = 2;
- }
-
- setAttr defaultResolution.height $requestedHeight;
- optionMenuGrp -edit -sl 1 resolutionMenu;
- checkMayaSoftwareAspectLockHeight "defaultResolution";
-
- // Set the proper field ordering if PAL or NTSC.
- if (`getAttr defaultResolution.height` == 576) // PAL
- {
- setAttr "defaultResolution.oddFieldFirst" 0;
- if (`columnLayout -exists rgFieldLayout`)
- {
- if (`exists updateFieldOptions`)
- {
- updateFieldOptions();
- }
- }
- }
- else if (`getAttr defaultResolution.height` == 486) // NTSC
- {
- setAttr "defaultResolution.oddFieldFirst" 1;
- if (`columnLayout -exists rgFieldLayout`)
- {
- if (`exists updateFieldOptions`)
- {
- updateFieldOptions();
- }
- }
- }
-
- // Update the values
- updateMayaSoftwareResolution();
- }
-
-
- global proc adjustMayaSoftwarePixelAspect(string $nodeName)
- {
- setParentToCommonTab();
-
- string $aspectAttr = $nodeName + ".deviceAspectRatio";
- string $widthAttr = $nodeName + ".width";
- string $heightAttr = $nodeName + ".height";
- float $pixelAspect = (float) `getAttr $widthAttr`
- / (float) `getAttr $heightAttr`;
- $pixelAspect = `getAttr $aspectAttr` / $pixelAspect;
- floatFieldGrp -e -v1 $pixelAspect pixRatio;
- }
-
- global proc adjustMayaSoftwareDeviceAspect(string $nodeName)
- {
- setParentToCommonTab();
-
- string $devAspectAttr = $nodeName + ".deviceAspectRatio";
- string $widthAttr = $nodeName + ".width";
- string $heightAttr = $nodeName + ".height";
-
- float $pixelAspect = `floatFieldGrp -q -v1 pixRatio`;
- float $aspect = (float) `getAttr $widthAttr`
- / (float) `getAttr $heightAttr`;
- $aspect = $pixelAspect * $aspect;
- setAttr $devAspectAttr $aspect;
- floatFieldGrp -edit -v1 $aspect resRatio;
- }
-
- global proc updateMayaSoftwareDeviceAspectRatio()
- {
- setParentToCommonTab();
-
- setAttr defaultResolution.deviceAspectRatio
- `floatFieldGrp -q -v1 resRatio`;
- adjustMayaSoftwarePixelAspect "defaultResolution";
- updateMayaSoftwareResolution();
- }
-
- // ----------------------------------------------------------------------------
- // Code to create and update the Render Options frame
- //
-
- proc createCommonRenderOptions()
- {
- string $parent = `setParent -query`;
-
- setUITemplate -pushTemplate attributeEditorTemplate;
-
-
- columnLayout -adjustableColumn true;
-
- attrControlGrp
- -attribute "defaultRenderGlobals.enableDefaultLight";
- attrControlGrp
- -attribute defaultRenderGlobals.pluginFormat
- -label "Plug-in Format";
- attrControlGrp
- -attribute defaultRenderGlobals.preRenderMel
- -label "Pre Render MEL"
- preRenderMelSwGrp;
- attrControlGrp
- -attribute defaultRenderGlobals.postRenderMel
- -label "Post Render MEL"
- postRenderMelSwGrp;
-
- if (`about -evalVersion`)
- {
- attrControlGrp -e -enable false preRenderMelSwGrp;
- attrControlGrp -e -enable false postRenderMelSwGrp;
- }
-
- setParent $parent;
- setUITemplate -popTemplate;
- }
-
- //==================================================================
- // Common Tab
- //==================================================================
-
- global proc updateMayaSoftwareCommonGlobalsTab()
- {
- //
- // Description:
- // This procedure is called when the current renderer changes to be the
- // Maya Software Renderer.
- // This procedure updates controls in the Common tab of the Maya Software
- // renderer to reflect values which may have been copied from the previous
- // current renderer.
- //
-
- updateMayaSoftwareFileNamePrefixControl();
- updateMayaSoftwareFileNameFormatControl();
- updateMayaSoftwareImageFormatControl();
- updateMayaSoftwareUseCustomExtensionControl();
- updateMayaSoftwareCustomExtensionControl();
- updateMayaSoftwareCameraControl();
- updateMayaSoftwareResolution();
- }
-
- global proc createMayaSoftwareCommonGlobalsTab()
- {
- //
- // Description:
- // This procedure is called when building the render globals tabs for the
- // Maya Software renderer.
- // This procedure builds the "General" tab for the Maya Software renderer.
- //
-
- string $renderer = "mayaSoftware";
-
- string $parentForm = `setParent -query`;
-
- createTargetFilePreview();
-
- setParent $parentForm;
-
- scrollLayout
- -horizontalScrollBarThickness 0
- scrollLayout;
-
- columnLayout
- -adjustableColumn true
- commonTabColumn;
-
- // Image File Name
- //
- frameLayout
- -label "Image File Output"
- -collapsable true
- -collapse false
- rgImageFileFrame;
-
- createCommonImageFile();
-
- setParent commonTabColumn;
-
- // Resolution Section
- //
- frameLayout
- -label "Resolution"
- -collapsable true
- -collapse false
- rgResolutionFrame;
-
- createCommonResolution();
-
- setParent commonTabColumn;
-
- // Render Options
- //
- frameLayout
- -label "Render Options"
- -collapsable true
- -collapse false
- mayaSoftwareOptionFrame;
-
- createCommonRenderOptions();
-
- setParent commonTabColumn;
-
- setParent $parentForm;
-
- formLayout
- -edit
- -af targetFilePreview "top" 5
- -an targetFilePreview "bottom"
- -af targetFilePreview "left" 0
- -af targetFilePreview "right" 0
- -ac scrollLayout "top" 5 targetFilePreview
- -af scrollLayout "bottom" 0
- -af scrollLayout "left" 0
- -af scrollLayout "right" 0
- $parentForm;
-
- // Update the target file preview.
- //
- updateMayaSoftwareTargetFilePreview;
- }
-
-